package com.cn.zpark;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Timer;

/**
 * @PackageName: com.cn.zpark
 * @ClassName: SessionDemo03
 * @Description:
 * @author: RZS
 * @date: 2022/4/14  14:44
 */
@WebServlet("/sd3.do")
public class SessionDemo03 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 获取session对象
        HttpSession session = request.getSession();
        // 获取session域数据
        Long tiem = (Long) session.getAttribute("tiem");
        String username = (String) session.getAttribute("username");
        System.out.println(tiem + " : " + username);

        // 获取session失效时间
        System.out.println(session.getMaxInactiveInterval());

    }
}
